<template>
	<view class="container-ship">
	  <view class="bottom">
	    <view v-for="(item,index) in list" class="list-view" @click="tap(index)" :key="index">
	      <view class="view-title">
	        <view v-if="item.order_type == 1">
	         预售发货
	        </view>
	        <view v-else>增补发货</view>
			<view v-if="item.order_type == 1">{{item.sizeorder_name}}
			</view>
	      </view>
	      <view class="data-bottom">
	        <view class="data-show">
	          <view>{{item.order_num}}</view>
	          <view>订单</view>
	        </view>
	        <view class="data-show">
	          <view>{{item.money}}</view>
	          <view>总金额</view>
	        </view>
	      </view>
	    </view>
	  </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				query:{
				      detailsDate:{year:'2020',month:'0'},
				      preDate:{year:'2020'}
				    }
			}
		},
		onLoad() {
			this.getShipList(1)
			this.getShipList(2)
			this.changedNaviTitle()
		},
		methods: {
			getShipList (type) {
			    var schoolId = this.$store.getters.currentSchool.school_id
				this.$api.getSendOutGoods({
			        school_id : schoolId,
			        order_type: type,
					time_year:this.query.detailsDate.year,
					time_month:this.query.detailsDate.month
			      }).then((rep) =>{
					  let {data} = rep.data
					  
					  let array =[]
					  if(type == 1){
						array = data
					  }else{
						array = [data]
					  }
					  
					  if(!this.list.length){
						  this.list = array
					  }else{
						  this.list = this.list.concat(array)
						  this.sortList(this.list)
					  }
				  })
			  },
			
			  sortList (ls) {
			    for (let i = 0; i < ls.length - 1; i++) {
					if(!ls[i].hasOwnProperty("order_type")){
							ls[i].order_type = '2'
						  }
					
			      if (parseInt(ls[i].order_type) > parseInt(ls[i + 1].order_type) ){
			        var temp = ls[i];
			        ls[i] = ls[i + 1]
			        ls[i + 1] = temp
			      }
			    }
				this.list = ls
			  },
			
			  changedNaviTitle () {
			    let school = this.$store.getters.currentSchool
				uni.setNavigationBarTitle({
				  title:school.school_name + '发货'
				})
			  },
			
			  tap (index) {
				  const item = this.list[index]
					let type = item.order_type
					const order_id = item.sizeorder_id
			    uni.navigateTo({
			      url: '../../refund/list/list' + '?type=' + type + '&source=2&order_id=' + order_id,
			    })
				
			  }
		}
	}
</script>

<style lang="scss">
.container-ship{
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.list-view{
  margin-left: 10rpx;
  margin-right: 10rpx;
  height: 300rpx;
  background-color: #F5F5F5;
  border: 1px solid #ddd;
  padding-bottom: 24rpx;
  margin-top: 24rpx;
}

.list-view:nth-child(1){
  margin-top: 0rpx;
}

.bottom{
  margin-top: 20rpx;
  width: 100%;
}
.data-bottom{
  display: flex;
  height: 80%;
}
.view-title{
  margin-top: 10rpx;
  padding-bottom: 10rpx;
  border-bottom: 1px solid #ddd;
  font-size: 14px;
}
.view-title > view{
  margin-left: 20rpx;
}
.data-show{
  width: 50%;
  display: inline-block;
  margin-top: 10rpx;
  text-align: center;
  align-self: center;
}
.data-show > view:nth-child(1){
  font-size: 30px;
}
.data-show > view:nth-child(2){
  font-size: 14px;
}
</style>
